package com.dinggao.bangda.data;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.dinggao.bangda.R;

import java.util.List;

/**
 * Created by Administrator on 2017/4/17.
 */

public class BeanAdapter extends RecyclerView.Adapter<BeanAdapter.ViewHolder>{
    private List<Bean> mBeanList;
    private Bean bean;

    public class ViewHolder extends RecyclerView.ViewHolder{
        View beanView;
        //初始化各控件
        TextView name;
        public ViewHolder(final View itemView) {
            super(itemView);
            beanView = itemView;
            //实例化各控件
            name = (TextView) itemView.findViewById(R.id.name_bean);

        }
    }
    public BeanAdapter(List<Bean> beanList){
        mBeanList = beanList;
    }
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_data_bean,parent,false);
        final ViewHolder holder = new ViewHolder(view);

        return  holder;
    }

    @Override
    public void onBindViewHolder(BeanAdapter.ViewHolder holder, int position) {
        bean = mBeanList.get(position);
        holder.name.setText(bean.getName_bean());
    }
    @Override
    public int getItemCount() {
        return mBeanList.size();
    }
}
